const { waitTime } = require('./common');
const fs = require('fs');

exports.getSingle = async function (numColis, driver) {
    const url = 'https://www.colisprive.com/agence/PageAgence/Colis/DetailColis.aspx?numColis=';
    driver.get(url + numColis);
    await waitTime(1000);
    driver.takeScreenshot().then((image, err) => {
        if (err) {
            console.error(JSON.stringify(err));
        }
        fs.writeFile(`file/out/${numColis}.png`, image, 'base64',  (err) => {
            if (err) {
                console.error(JSON.stringify(err));
            } else {
                console.log(`${numColis} done`);
            }
        });
    })
}